#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QColorDialog>
#include <QDebug>
#include <QPushButton>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //testGetColor();
    testSetColor();
}

void MainWindow::testSetColor()
{
    QPushButton* btn = new QPushButton("颜色对话框",this);
    QColorDialog* cdlg = new QColorDialog(this);

    connect(btn, &QPushButton::clicked, [=](){
        cdlg->setCurrentColor(QColor(200,100,190));

        cdlg->open();
    });
}

void MainWindow::testGetColor()
{
    QPushButton* btn = new QPushButton("颜色对话框", this);
    QColorDialog* cdlg = new QColorDialog(this);

    connect(btn, &QPushButton::clicked, [=](){
        QColor color = cdlg->getColor(QColor(255,0,0));

        qDebug() << color.red();
        qDebug() << color.green();
        qDebug() << color.blue();
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

